package com.jlmv.poseidon.view;
import java.io.Serializable;

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode;

@ManagedBean
@ViewScoped
public class TreeBean implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2023524722101427935L;
	private TreeNode root;

	@PostConstruct
	public void init() {
		root = new DefaultTreeNode("Root", null);
		TreeNode node0 = new DefaultTreeNode(
				"Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0", root);
		new DefaultTreeNode(
				"Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0", root);
		new DefaultTreeNode(
				"Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0", root);
		new DefaultTreeNode(
				"Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0", root);
		new DefaultTreeNode(
				"Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0", root);
		new DefaultTreeNode(
				"Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0", root);
		new DefaultTreeNode(
				"Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0", root);
		new DefaultTreeNode(
				"Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0", root);
		new DefaultTreeNode(
				"Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0Node 0", root);
		TreeNode node1 = new DefaultTreeNode("Node 1", root);
		TreeNode node2 = new DefaultTreeNode("Node 2", root);

		TreeNode node00 = new DefaultTreeNode("Node 0.0", node0);
		TreeNode node01 = new DefaultTreeNode("Node 0.1", node0);

		TreeNode node10 = new DefaultTreeNode("Node 1.0", node1);
		TreeNode node11 = new DefaultTreeNode("Node 1.1", node1);

		TreeNode node000 = new DefaultTreeNode("Node 0.0.0", node00);
		TreeNode node001 = new DefaultTreeNode("Node 0.0.1", node00);
		TreeNode node010 = new DefaultTreeNode("Node 0.1.0", node01);

		TreeNode node100 = new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
		new DefaultTreeNode("Node 1.0.0", node10);
	}

	public TreeNode getRoot() {
		return root;
	}

	public void mensaje() {
		FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO,
				"You said:' '", null);
		FacesContext.getCurrentInstance().addMessage(null, message);
	}
}